package com.example.module_car.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.module_car.R
import com.yuwei.http.entity.ProvincesEntity
import com.yuwei.http.entity.ProvincesEntityItem

class CarProvincesAdapter:BaseQuickAdapter<ProvincesEntityItem,BaseViewHolder>(R.layout.provinces_item) {
    private var position = -1
    fun setPosition(index:Int){
        this.position = index
    }
    override fun convert(holder: BaseViewHolder, item: ProvincesEntityItem) {
        if (position == holder.adapterPosition){
            holder.setText(R.id.provinces_text,item.abbreviation)
                .setBackgroundResource(R.id.provinces_text,R.drawable.car_provinces_bg1)
        }else{
            holder.setText(R.id.provinces_text,item.abbreviation)
                .setBackgroundResource(R.id.provinces_text,R.drawable.car_provinces_bg)
        }

    }
}